#include "../../include/dir.h"

// 打印当前路径信息
void print_path(path_t *p) {
    printf("虚拟路径: %s\n", p->virtualPath);
    printf("真实路径: %s\n", p->realPath);
}

int main() {
    path_t myPath;
    char buf[256] = {0};
    char input[128];

    // 初始化路径（假设真实根是 /home/meng）
    strncpy(myPath.initPath, "/home/meng", MAX_PATH_LEN);
    strncpy(myPath.virtualPath, "/", MAX_PATH_LEN);
    strncpy(myPath.realPath, myPath.initPath, MAX_PATH_LEN);

    printf("=== cd 测试程序 ===\n");
    printf("初始化虚拟路径: %s\n", myPath.virtualPath);
    printf("初始化真实路径: %s\n\n", myPath.realPath);

    const char *tests[] = {"/tmp", "logs", "..", ".", "./../tmp", "not_exist"};
    int testCount = sizeof(tests) / sizeof(tests[0]);

    printf(">>> 运行预置测试用例:\n");
    for(int i = 0; i < testCount; i++) {
        printf("测试 cd %s\n", tests[i]);
        if(handle_cd(&myPath, tests[i], buf, sizeof(buf)) == 0) {
            print_path(&myPath);
        } else {
            printf("错误: %s\n", buf);
        }
        printf("\n");
    }

    return 0;
}


